<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('学科导航')" />
    <th:block th:include="include :: ztree-css" />
</head>
<style>
    body{height:auto;font-family: "Microsoft YaHei";}
    button{font-family: "SimSun","Helvetica Neue",Helvetica,Arial;}


</style>
<body class="hold-transition box box-main">
    <input id="treeId"   name="treeId"    type="hidden" th:value="${bizSubject?.id}"/>
    <input id="treeName" name="treeName"  type="hidden" th:value="${bizSubject?.subjectName}"/>
    <div class="wrapper"><div class="treeShowHideButton" onclick="$.tree.toggleSearch();">
        <label id="btnShow" title="显示搜索" style="display:none;">︾</label>
        <label id="btnHide" title="隐藏搜索">︽</label>
    </div>
    <div class="treeSearchInput" id="search">
        <div class=" row">
            <label for="letter">拼音首字母：</label><input type="text" autocomplete="off" oninput="letterChange()" class="empty" id="letter" maxlength="50">
            <label for="keyword" style="margin-left: 20px">学科名称：</label><input type="text" autocomplete="off" class="empty" id="keyword" maxlength="50">
        </div>
    </div>
    <div class="treeExpandCollapse">
        <a href="#" onclick="$.tree.expand()">展开</a> /
        <a href="#" onclick="$.tree.collapse()">折叠</a>
    </div>
    <div id="tree" class="ztree treeselect"></div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: ztree-js" />
    <script th:inline="javascript">
        $(function() {
            var url = ctx + "biz/subject/treeData";
            var options = {
                url: url,
                expandLevel: 2,
                onClick : zOnClick
            };
            $.tree.init(options);
            setTimeout(function (){
                $.tree.expand();
            },50)


        });

        function zOnClick(event, treeId, treeNode) {
            var treeId = treeNode.id;
            var treeName = treeNode.name;
            $("#treeId").val(treeId);
            $("#treeName").val(treeName);
        }

        function letterChange(){
            const letter = $('#letter').val()
            console.log(letter)
            var nodes = $._tree.getNodes();
            $.tree.hideAllNode(nodes);
            // 根据搜索值模糊匹配
            $.tree.updateNodes($._tree.getNodesByParamFuzzy("pinYin", letter));
        }
    </script>
    <style>
        .select-list li input {
            border: 1px solid #ddd;
            border-radius: 4px;
            background: transparent;
            outline: none;
            height: 30px;
            /* width: 200px; */
            padding-left: 5px;
        }
    </style>
</body>
</html>